home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / SAFARI_I / COMPATIB.C next >
Text File  |  1991-10-01  |  1KB  |  60 lines

  1. /*
  2.     Determining whether _WaitNextEvent is available.
  3.     
  4.     These routines were converted to THINK C directly from the examples
  5.     show in Inside Macintosh Volume VI, page 3-8.
  6. */
  7.  
  8. #include <Traps.h>
  9.  
  10. int NumToolboxTraps(void);
  11. TrapType GetTrapType(int theTrap);
  12. Boolean TrapAvailable(int theTrap);
  13. Boolean WNEAvailable(void);
  14.  
  15. int NumToolboxTraps(void)
  16. {
  17.     if (NGetTrapAddress(_InitGraf, ToolTrap) ==
  18.         NGetTrapAddress(0xAA6E, ToolTrap))
  19.     {
  20.         return (0x200);
  21.     }
  22.     else
  23.     {
  24.         return (0x400);
  25.     }
  26. }
  27.  
  28. TrapType GetTrapType(int theTrap)
  29. {
  30.     #define TrapMask 0x800
  31.     
  32.     if ((theTrap & TrapMask) > 0)
  33.     {
  34.         return (ToolTrap);
  35.     }
  36.     else
  37.     {
  38.         return (OSTrap);
  39.     }
  40. }
  41.  
  42. Boolean TrapAvailable(int theTrap)
  43. {
  44.     TrapType tType;
  45.     
  46.     tType = GetTrapType(theTrap);
  47.     if (tType == ToolTrap)
  48.     {
  49.         theTrap = theTrap & 0x07FF;
  50.         if (theTrap >= NumToolboxTraps())
  51.             theTrap = _Unimplemented;
  52.     }
  53.     return (NGetTrapAddress(theTrap, tType) !=
  54.         NGetTrapAddress(_Unimplemented, ToolTrap));
  55. }
  56.  
  57. Boolean WNEAvailable(void)
  58. {
  59.     return (TrapAvailable(_WaitNextEvent));
  60. }